Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
smpte-timecode
Advanced tools
smpte-timecode
is a JavaScript library for operations with SMPTE timecodes.
string
(toString()
) and number
(valueOf()
);const Timecode = require('smpte-timecode')
var t = Timecode('00:15:10;03');
t.add('00:02:30;00');
console.log(t.frameCount);
t.subtract(100); //frames
console.log(t.toString());
Timecode = function (timecode, frameRate, dropFrame) {...};
timecode
: number, string or Date
"HH:MM:SS:FF"
(non-drop-frame) or
"HH:MM:SS;FF"
(drop-frame). The constructor will throw if the string contains invalid timecode, for example frame count above framerate or 0 frames in a drop-frame second.Date()
is passed, it is converted to the timecode a master
clock would have with a given framerate. Month, date and
year discarded.frameRate
: number (frames per second) or Array ([numerator,denominator]), optional
dropFrame
: boolean, optional
whether the timecode is using drop-frame or non-drop-frame mode.
If omitted, and timecode
is a string, the drop-frame mode is determined based on
the ":" or ";" characters separating the frames in the timecode
parameter.
If timecode
parameter is not a string, drop-frame assumed for 29.97 and 59.94 framerates, non-drop-frame for all others.
Examples:
var minute = new Timecode('00:01:00:00');
var eightHundredFrames = new Timecode(800,29.97,true);
var nineHundredFrames = new Timecode(900,[60000,1001],true);
var wallClock = new Timecode(new Date());
Note: a direct call to Timecode()
returns a Timecode
object too, so both direct
calls and instantiating with new
return the same result:
console.log((new Timecode('00:15:00;00')).toString());
// is the same as
console.log(Timecode('00:15:00;00').toString());
Once a Timecode
object is created, the following member variables are available:
frameCount
: number, total number of framesframeRate
: number, framerate in FPShours
: numberminutes
: numberseconds
: numberframes
: numberdropFrame
: boolean, whether timecode is drop-frame or notThe Timecode
object also provides the following member functions:
add(x)
: Timecode, adds x
to timecode, x
can be a number, Date
or Timecode
subtract(x)
: Timecode, subtracts x
from timecode, x
can be a number, Date
or Timecode
toString()
: string, returns the timecode in "HH:MM:SS:FF" or "HH:MM:SS;FF" formattoString('field')
: string, returns the timecode in VITC format, where timecodes above 30fps are represented as frame.field, i.e. HH:MM:SS:FF.ftoDate()
: date, returns a Date
object using today's date and timecode as wall clockvalueOf()
: number, returns this.frameCount
For more usage examples, see the unit tests.
To run tests, make sure you run
npm ci
The tests can be run in Node using:
npm test
npm run coverage
To run the tests in a browser environment, open the test/smpte-timecode-test.html
file
in a browser.
.ToString('field')
output in HH:MM:SS;FF.f format;License: MIT
Copyright © 2023 LTN Global Communications, Inc. http://www.ltnglobal.com
Copyright © 2017 Crystal Computer Corp. http://www.crystalcc.com
FAQs
JavaScript implementation of SMPTE timecode type
The npm package smpte-timecode receives a total of 3,098 weekly downloads. As such, smpte-timecode popularity was classified as popular.
We found that smpte-timecode demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.